using System.Collections.Generic;
using System.Threading.Tasks;
using JGSY.CMS.LowCode.Platform.Domain.Entities;

namespace JGSY.CMS.LowCode.Platform.Domain.Interfaces
{
    /// <summary>
    /// 内容仓储接口
    /// 提供内容模型、字段定义和内容项的数据访问操作，支持动态内容管理功能
    /// </summary>
    public interface IContentRepository
    {
        /// <summary>
        /// 获取所有内容模型
        /// </summary>
        /// <returns>内容模型实体列表</returns>
        Task<IEnumerable<ContentModel>> GetAllModelsAsync();
        
        /// <summary>
        /// 根据ID获取内容模型
        /// </summary>
        /// <param name="id">内容模型标识符</param>
        /// <returns>内容模型实体，如果未找到则返回null</returns>
        Task<ContentModel?> GetModelByIdAsync(long id);
        
        /// <summary>
        /// 创建新的内容模型
        /// </summary>
        /// <param name="model">要创建的内容模型实体</param>
        /// <returns>创建操作任务</returns>
        Task CreateModelAsync(ContentModel model);
        
        /// <summary>
        /// 更新内容模型
        /// </summary>
        /// <param name="id">内容模型标识符</param>
        /// <param name="model">更新后的内容模型实体</param>
        /// <returns>更新操作任务</returns>
        Task UpdateModelAsync(long id, ContentModel model);
        
        /// <summary>
        /// 删除内容模型
        /// </summary>
        /// <param name="id">内容模型标识符</param>
        /// <returns>删除操作任务</returns>
        Task DeleteModelAsync(long id);

        /// <summary>
        /// 获取指定模型的所有字段
        /// </summary>
        /// <param name="modelId">内容模型标识符</param>
        /// <returns>字段实体列表</returns>
        Task<IEnumerable<Field>> GetFieldsAsync(long modelId);
        
        /// <summary>
        /// 为模型添加字段
        /// </summary>
        /// <param name="modelId">内容模型标识符</param>
        /// <param name="field">要添加的字段实体</param>
        /// <returns>添加操作任务</returns>
        Task AddFieldAsync(long modelId, Field field);
        
        /// <summary>
        /// 更新模型字段
        /// </summary>
        /// <param name="modelId">内容模型标识符</param>
        /// <param name="fieldId">字段标识符</param>
        /// <param name="field">更新后的字段实体</param>
        /// <returns>更新操作任务</returns>
        Task UpdateFieldAsync(long modelId, long fieldId, Field field);
        
        /// <summary>
        /// 删除模型字段
        /// </summary>
        /// <param name="modelId">内容模型标识符</param>
        /// <param name="fieldId">字段标识符</param>
        /// <returns>删除操作任务</returns>
        Task DeleteFieldAsync(long modelId, long fieldId);

        /// <summary>
        /// 分页获取内容项
        /// </summary>
        /// <param name="modelId">内容模型标识符</param>
        /// <param name="page">页码，默认为1</param>
        /// <param name="limit">每页数量，默认为10</param>
        /// <returns>内容项实体列表</returns>
        Task<IEnumerable<ContentItem>> GetItemsAsync(long modelId, int page = 1, int limit = 10);
        
        /// <summary>
        /// 创建内容项
        /// </summary>
        /// <param name="modelId">内容模型标识符</param>
        /// <param name="item">要创建的内容项实体</param>
        /// <returns>创建操作任务</returns>
        Task CreateItemAsync(long modelId, ContentItem item);
        
        /// <summary>
        /// 根据ID获取内容项
        /// </summary>
        /// <param name="modelId">内容模型标识符</param>
        /// <param name="itemId">内容项标识符</param>
        /// <returns>内容项实体，如果未找到则返回null</returns>
        Task<ContentItem?> GetItemByIdAsync(long modelId, long itemId);
        
        /// <summary>
        /// 更新内容项
        /// </summary>
        /// <param name="modelId">内容模型标识符</param>
        /// <param name="itemId">内容项标识符</param>
        /// <param name="item">更新后的内容项实体</param>
        /// <returns>更新操作任务</returns>
        Task UpdateItemAsync(long modelId, long itemId, ContentItem item);
        
        /// <summary>
        /// 删除内容项
        /// </summary>
        /// <param name="modelId">内容模型标识符</param>
        /// <param name="itemId">内容项标识符</param>
        /// <returns>删除操作任务</returns>
        Task DeleteItemAsync(long modelId, long itemId);
    }
}
